class Student{
    public  String name;     //成员变量：分为静态成员变量和普通成员变量
    public  int age;
    public   static  int  className=316;
    public static void s(){
        System.out.println("静态方法");}

    @Override
    public String toString() {
      /*  return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';*/
        return "sys";
    }

    public  Student(String name, int age){
    this.name=name;
    this.age=age;
}

    public String name() {
        return name;
    }

    public Student (){
//        this.name = "键盘";
//        this.age = 2;
        this("李四",21);
        }
    public void eat(){         //成员方法：分为静态成员方法和普通成员方法
        System.out.println(this.name+"吃饭！");
    }
public void show() {
    System.out.println("姓名："+this.name+ " 年龄:"+this.age);

}


    /*静态代码块
* 一般用来初始化静态成员
* 来类加载的时候就被调用*/
    static {
        className=51;
    System.out.println("这是静态代码块！");
}
   /*构造代码块    也叫实例代码块    每有一个实例化就有一个输出
   * 注意实在类外*/
   {
       System.out.println("这是构造代码块！");
    }
}
public class test {

    public static void main(String[] args) {
        Student student=new Student("李四",10);
        Student student1=new Student("张三",15);
        Student student2=new Student("王麻子",20);
        System.out.println( Student.className);
        System.out.println(student1.name);
        Student.s();




    }
    public static void main1(String[] args) {
        //通过Student student=new Student();是实例化 对象
        Student student=new Student();
        Student student2=new Student();
        Student student3=new Student();
        student.show();
        student2.name="李四";
        student2.age=15;
        student2.show();
        Student.s();



    }


}
